﻿using SqlSugar;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;

namespace TaskManagement.Context
{
    public class DbFactory
    {
        public SqlSugarClient GetDbContext()
        {

            SqlSugarClient db = new SqlSugarClient(
            new ConnectionConfig()
            {
                ConnectionString = DBConfig.ConnectionString,
                DbType = DBConfig.dbType,//设置数据库类型
                IsAutoCloseConnection = true,//自动释放数据务，如果存在事务，在事务结束后释放
                InitKeyType = InitKeyType.Attribute, //从实体特性中读取主键自增列信息
                //InitKeyType = InitKeyType.SystemTable //初始化主键和自增列信息到ORM的方式
            });
            return db;
        }
    }
}